home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tcl / mxedit.tutorial < prev    next >
Encoding:
Text File  |  1992-07-15  |  28.5 KB  |  528 lines

  1.           --------------------------------
  2.                    Mx Tutorial #1:  Basic Editing
  3.           --------------------------------
  4.  
  5.                          by John Ousterhout
  6.          (updated for mxedit by Brent Welch)
  7.  
  8. This document is an introduction to Mx, which is a mouse-based editor for
  9. use with the X window system.  The best way to read this tutorial is on-line
  10. in an Mx window, so that you can try out the commands as they are introduced.
  11. To access this tutorial on-line, invoke the shell command "mxedit" with no
  12. arguments.
  13.  
  14. Simple Scrolling:
  15. ----------
  16. The first thing for you to learn is how to move around within a file, so that
  17. you can at least read the tutorial.  This is called "scrolling".  The easiest
  18. way to scroll is by "dragging" the document:  hold down the shift key with
  19. your left hand, place the pointer over the center of this window, press the
  20. left mouse button, and move the mouse up and down while holding the button
  21. down.  As you move the mouse, the document will move up and down in the
  22. window.  In the shorthand notation I'll use in the tutorial, what you just
  23. did is called "shift-left-dragging".  If you'd like to move the document
  24. more quickly, for example to browse through it quickly, try
  25. shift-right-dragging (use the right mouse button instead of the left).  In
  26. this case, the document will move a lot in response to very small mouse
  27. motions.
  28.  
  29. The vertical strip on the left side of the Mx window is called the
  30. "scrollbar".  A small box is displayed inside the scrollbar.
  31. I call this the "elevator".  Its height and location indicate which portion
  32. of the file is visible in the window.  For example, if the top of the
  33. elevator is at the top of the scrollbar and the bottom of the elevator
  34. is halfway down the scrollbar, it means that the first half of the file
  35. is visible in the window.  Try dragging up and down and see how the elevator
  36. moves.
  37.  
  38. You can also scroll by pressing mouse buttons with the pointer over the
  39. scrollbar.  Clicking on the arrows at either end of the scrollbar cause
  40. the display to scroll up or down by one line.  You can click on the elevator
  41. and drag it up or down and you'll get an effect similar to the shift-dragging
  42. described above.  If you click in the gaps between the elevator and the arrows
  43. then you scroll up or down one page.  In this case one line of context
  44. is kept so that, for example, clicking on the gap above the scrollbar the
  45. line at the top of the window will move to the bottom.
  46. If you have a reasonably fast display, you'll probably find that
  47. it's more convenient to scroll by dragging than by clicking in the scrollbar.
  48.  
  49. Basics:
  50. -------
  51. Mx is a simple editor that allows you to examine and modify text files.  It
  52. provides basic editing functions such as insertion, deletion, copying,
  53. searching, and substitution.  It also supports multiple windows.  You can
  54. display several different files at the same time in different windows and
  55. copy information back and forth between them, and you can look at several
  56. different regions of the same file at the same time using a different
  57. window for each region.
  58.  
  59. Each Mx window contains several subwindows.  The top-most subwindow is
  60. normally a title bar displayed by the window manager.
  61. The title bar displays the name of the file
  62. you're editing.  If you've modified the file, then an exclamation point
  63. will appear after the file's name (or the word "Modified" will appear
  64. at the right side of the title bar).  Just underneath the title bar is
  65. the "menu bar", which contains the names of several pull-down menus.
  66. At the bottom is a message window, which currently gives the name
  67. and size of this file. Information and error messages will appear in
  68. the message window at various times during editing.  At the left side
  69. of the window is the scrollbar, which you're already familiar with.
  70. The rest of the window displays a few lines of the file you're editing.
  71. A few other subwindows will appear later on, while you're editing. For
  72. example, one of them will be used to enter strings for searching and
  73. replacement.
  74.  
  75. There are three ways that you can invoke operations in Mx: by positioning the
  76. pointer over the text of the file and clicking or dragging with the mouse, by
  77. typing keys on the keyboard, or by selecting menu entries with the mouse.
  78. For a simple example of each of these, first move the pointer over the leftmost
  79. "X" in the line below and left-click.  A little upside-down "V", called the
  80. "caret", will appear just to the left of the X.
  81.  
  82.             XXXX - play here
  83.  
  84. Second, type some characters on the keyboard.  Each keystroke invokes an Mx
  85. command to insert that character into the file just before the caret.  As
  86. you'll see later, various special keys, such as the control keys, can be used
  87. to invoke other Mx commands such as copying and deleting text.  Finally, for
  88. an example of a menu selection, move the pointer up to the menu bar (it's
  89. the horizontal strip at the top of the window just underneath the striped
  90. title bar), and position it over the word "Edit".  The word will highlight.
  91. Press the left mouse button and hold it down.  This causes a menu to appear
  92. underneath the pointer.  With the button held down, drag the pointer down
  93. through the menu until the word "Undo" is highlighted, then release the mouse
  94. button.  This invokes the undo command, which will remove all the text you
  95. just typed in.
  96.  
  97. Each word in the menu bar corresponds to a different menu.  To scan through
  98. the menus, press the left mouse button with the pointer over "File", and
  99. hold the button down.  Then drag the pointer to the right so that it passes
  100. in turn over each of the other words in the menu bar.
  101.  
  102. When an error occurs while Mx is executing a command, Mx will tell you in
  103. one of two ways.  For short messages, Mx will place the message in the message
  104. subwindow.  If an error message is long,
  105. or if Mx needs for you to make a decision, it will pop up a special window
  106. called a "notifier".  The notifier contains a message plus one or more options,
  107. which appear at the top of the notifier.  When you see a notifier, you must
  108. click on one of the options in order to tell Mx what to do. 
  109. For example, insert some
  110. characters in this file then invoke the "Quit" entry in the "File" menu.
  111. A notifier will warn you that you're about to lose the changes you just
  112. made to this file.  Click a mouse button on the "Skip command" option.
  113.  
  114. The Caret and Insertion:
  115. ------------------------
  116. The simplest operation in Mx is insertion.  If you type normal characters on
  117. the keyboard, they will be inserted in the file at the position of the caret.
  118. You can position the caret anywhere in the file by left-clicking or
  119. left-dragging.  If you make mistakes while you're typing, you can type
  120. control-h, BACKSPACE, or DELETE to delete the character just before the caret.
  121. Control-w will delete the entire word that precedes the caret.  Try inserting
  122. text at various positions within this file.
  123.  
  124. The Selection:
  125. --------------
  126. The selection is a special range of text used in operations like copying
  127. and deletion.  To select a range of characters, position the caret at one
  128. end of the range, then move the pointer to the other end of the range and
  129. right-click.  All of the characters between the caret and the pointer will
  130. become highlighted.  These characters constitute the selection.  Try changing
  131. the selection by moving the pointer somewhere else and right-clicking.  You
  132. can drag the end of the selection by moving the mouse with the right button
  133. held down, just as you can drag the caret by moving with the left button
  134. down.  Try selecting various ranges of text in this tutorial.  There can
  135. only be one selection at a time:  when you make one selection, the previous
  136. one disappears.
  137.  
  138. There are additional selection modes called "word selection" and "line
  139. selection".  To invoke word selection, point to a character in the middle of
  140. a word and left-click twice in a row (quickly) without moving the mouse.
  141. This is called "double-clicking", and will cause the entire word to be
  142. selected.  When you right-click now, Mx will ensure that only whole-words
  143. are selected.  If you triple-click the left button, then Mx will force the
  144. selection to consist of entire lines of the file.  Try making word and line
  145. selections.
  146.  
  147. A word is any collection of adjacent letters and digits.  Each punctuation
  148. character is considered to be a word by itself, except that the bracket
  149. characters "()[]{}<>" are treated specially.  When you use word selection
  150. on a bracket character, Mx finds the matching bracket and selects the entire
  151. range, including the open and close brackets.  Brackets may be nested.
  152. Double-click in the code fragment below and hold the left button down during
  153. the second click.  Then drag the pointer around to see what happens when it
  154. passes over the various brackets:
  155.  
  156.         if (template != NULL) {
  157.             x = (foo[index+2, y] + (x/y)*42)/(y+1);
  158.             y = 0;
  159.         }
  160.  
  161. If you only want to select a single character, there is a faster way than
  162. first left-clicking to position the caret at one side of the character and
  163. then right-clicking to select the character.  Instead, "roll" the mouse
  164. buttons: press left then immediately press right before you've released left.
  165. This will select the character under the pointer and also place the caret
  166. at the left side of the character.  If you hold one or both of the mouse
  167. buttons down after you've rolled, you can drag both the caret and the
  168. selection.
  169.  
  170. There are times when it's convenient to make a selection without moving
  171. the caret (e.g., you've already got the caret where you want it and you'd
  172. like to select some text to copy to the caret position).  To do this, hold
  173. the control key down while you select.  Control-left-click will select the
  174. character under the pointer without moving the caret, and control-right-click
  175. will select the range of characters between the pointer position and the
  176. character that you selected with control-left-click.
  177.  
  178. Copying and Deleting:
  179. ---------------------
  180.  
  181. The selection is used for many purposes in Mx, the most common of which are
  182. deleting and copying.  You can delete a range of text by selecting the text
  183. and then invoking the "Delete SEL" entry in the "Edit" menu.  Throughout
  184. the Mx menus, the term "SEL" refers to the selection.  Note that you can
  185. select the newline character at the end of a line (when it's selected, all of
  186. the white space at the end of the line is highlighted);  if you delete the
  187. newline character, the following line will be joined to the current line.
  188.  
  189. The "Paste" entry in the "Edit" menu will insert a copy of
  190. the selection at the position of the caret, even if the selection currently
  191. belongs to some other X tool.  The "Move SEL" entry in the "Edit" menu will
  192. move the selection to the caret position, but only if the selection is in
  193. the current window.
  194. Some people find it most convenient to first select the text to be copied
  195. or moved and then position the caret at the destination;  others find it more
  196. convenient to position the caret first, then hold the control key down while
  197. selecting the text.  Try using copy and delete to exchange the words "red"
  198. and "house" in the sentence below.  Then use move to put "red" back where it
  199. was originally.
  200.  
  201.         Thank goodness they're repainting their house red.
  202.  
  203. Cut and Paste with the Function Keys:
  204. -------------------------------------
  205. Some keyboards have function keys labeled "Cut", "Paste", and so on.
  206. These keys are bound to the corresponding operations, at least they
  207. are for the Sun keyboards.  There is, however, one subtle difference in the
  208. way Mx manages the selection and the way it is done by other tools.
  209. There is no explicit "Copy" operation in Mx.  Instead, when you make
  210. a selection using the mouse it is automatically registered as the
  211. primary X selection.  The good part of this is that it is fast and
  212. easy to select something.  The down-side is that it is also easy
  213. to accidentally make a new selection and make Mx forget what was
  214. selected previously.  Another difference is that many applications
  215. use "Cut" to put things into the X "cut buffer", with "Paste" being
  216. used to insert the contents of the cut buffer. For now, anyway, Mx
  217. just implements a per-window cut buffer so that pressing "Cut" and then
  218. "Paste" in the same window will work as you expect.  However, if there
  219. is a primary selection registered (i.e., if you have selected text in Mx),
  220. then "Paste" will insert that instead of the contents of the per-window
  221. cut buffer.  Also, "Cut" then "Paste" won't work between windows.
  222. Instead, to transfer information between windows, just select it
  223. in the Mx window, and then use "Paste" to copy it into another X tool.
  224. Finally, Mx has a "Move SEL" menu entry that will move the selection to
  225. where the current insert point is, which is equivalent to Cut-then-Paste.
  226.  
  227. Saving Files and Leaving the Editor:
  228. ------------------------------------
  229. When you're ready to leave the editor, select the "Quit" entry in the
  230. "File" menu.  This will destroy the X window.  It will also end the
  231. execution of Mx, if there are no other Mx windows open.
  232.  
  233. When you make changes to a file in Mx, those changes are not automatically
  234. reflected in the original copy of the file on disk.  To change the disk
  235. version of the file, you must "save" the file.  The "Save" entry in the
  236. "File" menu will write the file back to disk.  Or, if you've modified the
  237. file and then try to quit without saving the file, Mx will warn you with
  238. a notifier and give you a chance to save the file or skip the quit command.
  239.  
  240. If you'd like to save the edits in a different file than the one you started
  241. out with, select the name of the file you'd like to save into and then invoke
  242. the "Save in file SEL" entry in the "File" menu.  The only problem
  243. here is how to get the file name someplace where you can select it.  If it
  244. already appears on the screen somewhere, just select it.
  245. As a last resort, open the command subwindow by invoking
  246. the "Command" in the "Window" menu.  The cursor (a thin vertical line) should
  247. appear in the small subwindow that just appeared at the bottom of the
  248. window.  Then type the file name there and select it for use in saving
  249. the file, or go ahead and type "save filename" to the Command: prompt.
  250. After saving the file, you can make the command subwindow go
  251. away by getting the caret into the command subwindow (if it isn't there
  252. already, invoke the "Open command subwindow" menu entry again, or left-click
  253. in the command subwindow) and typing control-q.  In general, typing
  254. control-q in an Mx window or subwindow is a request to make the (sub)window
  255. go away.
  256.  
  257. Bindings:
  258. ----------
  259. The menus are convenient for learning because they're easy to browse through
  260. to find commands.  However, if you use the menus a lot you won't be able to
  261. edit very quickly.  Fortunately, many of the Mx commands can be invoked
  262. by typing keys as well as by selecting menu entries.  The keystrokes are
  263. called "bindings":  a particular key or sequence of keys is "bound" to an
  264. Mx command.  If there is a keystroke sequence equivalent to a menu entry,
  265. the binding appears at the right side of the menu entry.  For example, the
  266. "Paste" entry in the "Edit" menu shows the binding <Control-v>.
  267. The "Delete" entry in the same menu has the
  268. binding <Control-d>.  These two bindings and the control-q binding
  269. mentioned above are the most important ones;  I suggest that you learn
  270. them immediately and use them instead of the menu entries.  You can
  271. gradually learn other bindings as you become more familiar with the system.
  272. To get information about all of the default bindings, invoke the
  273. "Show key bindings" entry in the "Help" menu.
  274.  
  275. The binding <Mod1-x> in a menu means "meta-x", which means different things
  276. on different keyboards.  On Sun-4 keyboards, the meta key is labeled "Alt".
  277. Use the meta key like the control key, hold it down while pressing the
  278. other key given in the binding sequence.  In contrast, the Escape key
  279. is used by first pressing the Escape key and then pressing another key.
  280. Bindings for escape sequences look like <Escape><x>.
  281.  
  282. You can change the bindings to eliminate old ones and define new ones if
  283. you wish.  You can also modify the menus, or even change the meanings of
  284. normal keystrokes (for example, you could arrange things so that typing
  285. the space character caused the selection to be deleted, if that turned out
  286. to be desirable).  For more information, see the section below on
  287. Customizing the Editor.
  288.  
  289. Undoing and Crash Recovery:
  290. ---------------------------
  291. While you edit, Mx keeps a log of every modification that you make to the
  292. file.  The log is used for two purposes:  undoing and recovery.  If you ever
  293. make a change and then wish you hadn't, you can invoke the "Undo" entry in
  294. the "Edit" menu or type the <Control-u> binding.  This will cause the last
  295. modification you made to the file to be undone.  If you undo several times
  296. in a row without any intervening file modifications, each invocation will undo
  297. the next older action, all the way back to the beginning of the edit session.
  298. Make a series of changes to this file, then undo them. 
  299.  
  300. Normally, each user-invoked action, such as a keystroke or button click or
  301. menu selection, constitutes one event as far as undoing is concerned.  Thus
  302. if you copy a huge selection, the whole copy will be undone at once.  The
  303. only exception to this rule is that if you type in a bunch of text on the
  304. same line, then all of the text will be undone together (i.e. you don't have
  305. to invoke undo once for each character; use backspace or control-W if you
  306. only want to erase a few characters).  If you type in many lines of text in
  307. a row, then the type-in will be undone one line at a time.
  308.  
  309. The undo actions are recorded in the log, so they can be undone also. However,
  310. if you undo something and then wish you hadn't, you can't just undo again:
  311. that will undo the next next older action, rather than undoing the undo.
  312. Instead, hit the space bar, which inserts a space character in the file.
  313. This (or any other modification to the file) resets the undo mechanism so that
  314. the next undo refers to the most recent modification to the file;  now invoke
  315. undo twice:  the first will undo the space insertion and the second will undo
  316. the unwanted undo.
  317.  
  318. The second purpose of the log is to allow recovery if Mx crashes during an edit
  319. session or if your machine goes down unexpectedly.  If a crash occurs, the
  320. log file will be left on disk.  The log file has a name beginning with "Mx"
  321. and is usually stored in the directory containing the file being edited.  If
  322. that directory isn't writable, then Mx stores the log file in your home
  323. directory.  To recover all the changes you made during a crashed edit
  324. session, just re-run Mx on the same file.  Mx will locate the log file [and
  325. pop up a notifier giving you the choice of recovering or deleting the old
  326. log file.  If you select recovery,] Mx will scan through the log file and
  327. update the file to reflect all of the changes made in the crashed edit
  328. session.  With the recovery mechanism, you should never lose any modifications
  329. except for those on the line where you were working when the crash occurred.
  330. You can try out the recovery features by starting up Mx and then killing it
  331. from the shell.
  332.  
  333. Searching and Substitution:
  334. ---------------------------
  335. Mx provides mechanisms that allow you to search through a file for a
  336. particular sequence of characters, or to replace a given sequence of
  337. characters with another sequence provided by you.  To see how this works,
  338. invoke the "Forward" entry in the "Search" menu.  The first time you
  339. invoke this operation, Mx will open a new subwindow just under the menu bar,
  340. called the "search subwindow".  It contains two entry areas, where you can
  341. type in a search string and a replacement string.  To enter a search string,
  342. get the caret into the search entry (if it isn't already there) by moving
  343. the pointer over the entry and left-clicking.  Now you can type in a search
  344. string.  The editing characters <Control-h> and <Control-w>
  345. work in the search subwindow,
  346. and you can also use the selection and <Control-d> to edit the search and
  347. replacement strings.  You can use <Control-v> to copy information from almost
  348. anywhere on the screen to the search and replacement strings.
  349.  
  350. Enter the characters "the" as the search string.  There are four different
  351. ways you can invoke searching now.  The simplest is to press RETURN in the
  352. Search window, or you can re-invoke the "Forward" entry in the
  353. "Search" menu.  Mx will search for the next occurrence
  354. of the string "the", starting at the caret location, and will select that
  355. occurrence.  You can also search using the <Control-f> binding in the
  356. main window, [or by middle-clicking on the search string].
  357. These four approaches all produce the same result.  The
  358. "Search" menu provides a "Backward" entry to scan in the opposite
  359. direction.  If one end of the file is reached during a search, Mx skips to
  360. the opposite end of the file and continues.
  361.  
  362. If you don't want to type the search string into the search subwindow, you
  363. can also select the string you'd like to search for and use the
  364. "Forward for SEL" and "Backward for SEL" menu entries.
  365.  
  366. To make substitutions, enter a replacement string into the search subwindow
  367. and invoke the "Replace" command in the "Search" menu.  This will replace
  368. the selection with the replacement string.  You can also invoke replacement
  369. by typing RETURN in the replacement string, [by middle-clicking on the
  370. replacement string], or by typing the <Control-r> binding in the main window.
  371.  
  372. You can move the focus from the Search entry to the Replace entry with
  373. the binding <Control-r>.  You can move the focus from the Replace entry
  374. to the search entry with the <Control-f> binding.
  375.  
  376. By default, search and replacement strings are regular expressions in
  377. the style of the vi text editor.  If you'd prefer for searching and
  378. replacement to be done by exact matches only, without regular expressions,
  379. set the "noRegExps" variable to 1.
  380.  
  381. If you'd like to replace all the instances of one string by another string,
  382. you have two choices.  One possibility is repeatedly to type
  383. <Control-f> and <Control-r>
  384. to step through the instances one at a time.  Or, you can select a range of
  385. text in which you'd like to make the substitution and invoke the
  386. "Replace in SEL" entry in the "Search" menu.  This will replace
  387. all instances of the search string in a single operation.  Try using these
  388. commands to replace "the" with "my" in several areas of this document.
  389. The "Replace in SEL" command is bound to <Mod1-r>.
  390. The "Replace Everywhere" entry in the "Search" menu will make the
  391. substitution throughout the file.
  392.  
  393. Two other bindings are useful when searching and replacing:  <Escape><f> will
  394. clear the search string entry and move the caret there, so you can type
  395. in a new search string;  and <Escape><r> will clear the replacement string
  396. entry and move the caret there
  397.  
  398. When you no longer need the search subwindow, you can get rid of it by
  399. getting the caret into it (left-click on the window if necessary) and
  400. typing "C-q".
  401.  
  402. Using Multiple Windows:
  403. -----------------------
  404. Mx allows you to open several windows on the same or different files and
  405. copy information back and forth between them.  Invoke the "Open" entry in
  406. the "File" menu.  The new window will display the same file
  407. as the old window, and you can modify the file from either window.  Try making
  408. changes in both windows:  you'll see the selection and the changes in each of
  409. the windows.  You can also open a new window on a different file by selecting
  410. the file's name and invoking the "Open file SEL" entry in the "File"
  411. menu.  Once this is done, you can use the selection to copy information back
  412. and forth between the windows.
  413.  
  414. The "File" menu also includes additional entries for switching the current
  415. window from one file to another ("Switch to file SEL"), opening a new window (or
  416. switching the current window) to display the definition of a symbol using the
  417. tags facility, and adjusting the view in a window to display a particular line
  418. number (e.g. for compiler error messages).
  419.  
  420. Indentation:
  421. ------------
  422. Mx automatically manages line indentation.  Whenever you type RETURN to start
  423. a new line, Mx will indent the new line to match the indentation of the
  424. previous line.  Whenever you move the caret away from a line Mx will clean up
  425. the line's indentation:  if there is any white space at the beginning of the
  426. line, Mx replaces as much of it as possible with tabs (one tab for each eight
  427. spaces).  In the lines below, position the caret at the end of the various
  428. lines and type RETURN to see how auto-indentation works:
  429.  
  430.         This line is indented.
  431.             This line is indented even more.
  432.  
  433. The "Edit" menu provides several commands to modify the indentation of
  434. lines.  First, the variable "indent" is used to keep the current value
  435. of indentation.  This defaults to 4, although you can change this in
  436. your .mxedit file.  "Indent SEL" will shift all the lines in the selection
  437. right by $indent spaces, and "Outdent SEL" will shift the lines left
  438. by $indent spaces.  "Indent line" and "Outdent line" do the same
  439. thing for the line containing the caret.
  440.  
  441. History and Repeating Commands:
  442. -------------------------------
  443. Mx automatically records commands you've invoked so that they can
  444. be replayed later.  For full details, read about the "history" command in
  445. the manual page.  The simplest mechanism is "Do again", which is
  446. available in the "Edit" menu or with the <Control-a> binding.  This will
  447. repeat all the commands you invoked between the last two button presses,
  448. searches, or undos.  For an example of how this works, select "Test"
  449. below, then delete it and type "Foo" in its place.  Then select "Test2",
  450. and type <Control-a>;  you can continue with "Test3" and "Test4" also.
  451.  
  452.         Test        Test2        Test3        Test4
  453.  
  454. Command subwindow:
  455. ------------------
  456. The command subwindow is displayed at the bottom of the window along
  457. with the "Command:" prompt.  The things you type into this window
  458. are interpreted as TCL commands, so you can play around a bit.  This
  459. is useful to test out customizations as described below.  I also find
  460. it easiest to open new windows and switch among files using the command
  461. window.  You can display the command window if it isn't already visible
  462. by typing <Control-c> in the main editing window, or by selecting the
  463. "Open command window" entry in the Window menu.  You can hide the command
  464. window by typing <Control-q> in the command window or by selecting
  465. the "Hide command window" entry in the Window menu.
  466.  
  467. Customizing the Editor:
  468. -----------------------
  469. You probably hate the built-in keystroke bindings already, plus you
  470. can imagine more menus that you'd like to add to the editor.
  471. These are all defined by TCL commands, so you can change these
  472. by putting TCL commands into a file called ".mxedit".  The editor
  473. looks in your home directory and in the current directory for these
  474. files each time it creates a new top-level window.  You can define
  475. new keystroke bindings, menus, and TCL procs.  If you want to
  476. get serious you should look at the mxedit.* scripts in the
  477. TCL library directory to see how the base editor is implemented.
  478. You'll also want to understand how mxedit uses marks, which is
  479. explained in README.mxedit
  480.  
  481. The mxBind command binds a key sequence to a command.  It is a thin
  482. layer on top of the TK bind command, so you should read the TK
  483. bind man page for details.
  484.     man -M /project/tcl/man bind
  485. The command can be any TCL proc, including
  486. those defined in mxedit.utils and those you define yourself.  Try
  487. grepping through mxedit.utils for '^#.* --' to get a list of the
  488. procs defined there.  Look also at mxedit.bindings to see how the
  489. default keystroke bindings are setup. Here is a silly example that
  490. binds <Control-x> to look for the string "foo":
  491.  
  492.     mxBind <Control-x> { search forw "foo" }
  493.  
  494. You'll note that the menus list keyboard accelerators in them.  It
  495. is possible to change keyboard bindings and update the menus at
  496. the same time by using the "mxMenuBind". In this case you specify
  497. a binding for a particular menu entry, and the procedure takes care
  498. of updating the menu to display the right accelerator:
  499.  
  500.     mxMenuBind <Control-f> Search "Forward"
  501.  
  502. If you want to add a new menu use mxMenu to initialize it:
  503.  
  504.     mxMenu Test
  505.  
  506. and then add things to it with mxMenuAdd
  507.  
  508.     mxMenuAdd Test "Do Something"    { global a ; set a 5 }
  509.     mxMenuAdd Test "See Something"    { global a ; set a }
  510.  
  511. and perhaps add a keyboard accelerator with mxMenuBind
  512.  
  513.     mxMenuBind Test "Do Something"    <Control-x>
  514.  
  515. Occasionally you'd like to change a menu's appearance as the result
  516. of running a command.  Use mxMenuEntryConfigure:
  517.  
  518.     mxMenuEntryConfigure Test "Do Something" -label "Do Something Else" \
  519.                          -command { global a ; set a -5 }
  520.  
  521. All the mxMenu* commands are thin layers on top of the TK menu commands
  522. so you can consult the TK menu man page for details if you run into
  523. problems.  The main difference is that the mxMenu* routines keep track
  524. of menus by their button label (e.g., "File") instead of an internal TK
  525. widget name (e.g., ".buttons.FileMenu").  Also, all keystroke sequences
  526. are bound to the main edit window.  You'll have to come up with a new
  527. procedure based on mxMenuBind if you want to change that property.
  528.